<?php
declare (strict_types=1);

namespace app\index\controller;

use app\BaseController;
use app\common\library\HproseClient;


class Index extends BaseController
{
    public function index()
    {
        $id = $this->request->get('id', 2);
        $Lock = new \RedisLock();
        $res = $Lock->lock('123', 10);
        if (!$res) {
            return '排队中';
        }

        //处理业务逻辑
        sleep(1);
        $data = [
            HproseClient::ins('index')->get((int)$id),
            HproseClient::ins('client')->get(1)
        ];


        $Lock->unlock('123');
        return json($data);
    }


}
